home *** CD-ROM | disk | FTP | other *** search
- #include <dlfcn.h>
- #include <stdio.h>
-
-
- main() {
- char choice;
- void *handle;
- void (*msg)(int);
-
- printf("What language would you like your messages in?\n\n");
- printf(" 1: English\n\n");
- printf(" 2: Spanish\n\n");
- printf(" 3: German\n\n");
- printf(" 4: French\n\n");
-
- scanf("%c", &choice);
-
- switch (choice) {
- case '1':
- handle = dlopen("english.so", RTLD_LAZY);
- break;
-
- case '2':
- handle = dlopen("spanish.so", RTLD_LAZY);
- break;
-
- case '3':
- handle = dlopen("german.so", RTLD_LAZY);
- break;
-
- case '4':
- handle = dlopen("french.so", RTLD_LAZY);
- break;
-
- }
-
- if (handle == NULL) {
- fprintf(stderr, "%s\n", dlerror());
- exit(1);
- }
-
- msg = dlsym(handle, "message");
- if (msg == NULL) {
- fprintf(stderr, "%s\n", dlerror());
- exit(2);
- }
-
- (*msg)(1);
-
- (void) getc(stdin);
- }
-